part of '../repository.dart';

const _kEnUILocaleValue = 'en';
const _kRuUILocaleValue = 'ru';

class _UILocaleDto extends Equatable {
  const _UILocaleDto._internal({
    required this.uiLocaleString,
  });

  final String uiLocaleString;

  @override
  List<Object?> get props {
    return [
      uiLocaleString,
    ];
  }

  factory _UILocaleDto.fromString(String uiLocaleString) {
    return _UILocaleDto._internal(
      uiLocaleString: uiLocaleString,
    );
  }

  factory _UILocaleDto.fromEntity(UILocale uiLocale) {
    final uiLocaleString = switch (uiLocale) {
      UILocale.en => _kEnUILocaleValue,
      UILocale.ru => _kRuUILocaleValue,
    };

    return _UILocaleDto._internal(
      uiLocaleString: uiLocaleString,
    );
  }

  @override
  String toString() {
    return uiLocaleString;
  }

  UILocale toEntity() {
    return switch (uiLocaleString) {
      _kEnUILocaleValue => UILocale.en,
      _kRuUILocaleValue => UILocale.ru,
      _ => throw UnimplementedError(),
    };
  }
}
